﻿<%@ Page Title="" Language="C#" MasterPageFile="~/master/m.master" %>

<script runat="server"></script>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <link href="../assets/css/shelf/base.css" rel="stylesheet">
    <link href="../assets/css/report/intelligent.css" rel="stylesheet" />
    <style type="text/css">
        .system-box .right-side {
            width: 100%;
        }

        .inmodal .modal-body {
            padding: 10px;
        }

        @media (min-width: 768px) {
            .modal-dialog {
                /*width: 1080px;*/
                width: 1065px;
                margin: 30px auto;
            }
        }


        .no-padding-lb {
            padding-right: 0px;
            padding-left: 0px;
            font-size: 12px;
            margin-top: 4px;
        }

        .condition {
            overflow: inherit !important;
        }

        .no-padding-in {
            padding-right: 0px;
            padding-left: 0px;
        }

        .margin2font {
            margin-left: 35px !important;
        }

        .condition_sm {
            padding-left: 10px !important;
            padding-right: 2px !important;
            margin-right: -40px !important;
        }

        .condition_toggle {
            width: 330px;
        }

            .condition_toggle .input-sm {
                padding: 0px;
            }

        .caret {
            color: white;
        }

        .thisBtn {
            padding-left: 6px !important;
            margin-top: -1px !important;
            height: 29px;
        }

        .row {
            margin-right: 0px !important;
        }

        .btn-primary {
            background-color: #1dc5a3 !important;
        }
        /*如果近七个有效日日均销售量需要显示两位小数，则使用此样式*/
        /*
        .SevenDay {
        min-width:45px !important;
        max-width:45px !important;
        }*/

        /*测试用*/
        /*.td-bg-style1 {
            color: black;
        }
        .td-bg-style2{
            color: red;
        }
        .td-bg-style3 {
            color:green
        }
        .td-bg-style4{
            color: blue;
        }*/
    </style>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="main" runat="Server">
    <div class="system-box">
        <div class="right-side">
            <div class="btns-container">
                <div class="modal inmodal" id="auxiliary" tabindex="-1" role="dialog" aria-hidden="true">
                    <div class="modal-dialog">
                        <div class="modal-content animated fadeIn">
                            <div class="modal-header">
                                <span class="editTitle">补货辅助信息</span>
                                <button type="button" class="close" data-dismiss="modal">
                                    <span aria-hidden="true">&times;</span>
                                    <span class="sr-only">关闭</span>
                                </button>
                            </div>
                            <div class="modal-body">
                                <div style="width: 1060px; height: 360px; overflow: auto; margin: 0 auto;">
                                    <table id="auxiliaryTable" style="width: 2060px;">
                                        <thead>
                                            <tr>
                                                <th>店铺</th>
                                                <th>货号</th>
                                                <th>尺码</th>
                                                <th>累计销售</th>
                                                <th>累计调入</th>
                                                <th>生命周期内销售数量</th>
                                                <th>生命周期内调入数量</th>
                                                <th>周销售</th>
                                                <th>周调入</th>
                                                <th>有效天数</th>
                                                <th>近七个有效日累计销量</th>
                                                <th>日均售量</th>
                                                <th>上市日期</th>
                                                <th>上市天数</th>
                                                <th>日均售罄率</th>
                                                <th>近一周畅滞销状态</th>
                                                <th>区间补货系数</th>
                                                <th>是否核心码</th>
                                                <th>陈列量</th>
                                                <th>理想水位</th>
                                                <th>目标水位</th>
                                                <th>补货需求</th>
                                                <th>在仓库存</th>
                                                <th>在途库存</th>
                                                <th>订单在途</th>
                                                <th>库存数量</th>
                                                <th>两周内是否有调出</th>
                                            </tr>
                                        </thead>
                                        <tbody id="auxiliaryList"></tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="condition-container">

                <div class="left-condition">
                    <div class="condition-title">查询条件</div>
                    <div class="condition row">
                        <div class="col-sm-3 condition_sm">
                            <label>发货仓库</label>
                            <select class="form-control input-w110" id="serarch-warehouse">
                                <option value="">请选择</option>
                            </select>
                        </div>
                        <div class="col-sm-3 condition_sm">
                            <label class="margin2font">省份</label>
                            <select class="form-control input-w110" id="serarch-province">
                                <option value="">请选择</option>
                            </select>
                        </div>
                        <div class="col-sm-3 condition_sm">
                            <label class="margin2font">城市</label>
                            <select class="form-control input-w110" id="serarch-city">
                                <option value="">请选择</option>
                            </select>
                        </div>
                        <div class="col-sm-3 condition_toggle">
                            <label>货品款型</label>
                            <div class="input-group">
                                <input type="text" class="form-control input-sm" id="serarch-style">
                                <div class="input-group-btn input-sm thisBtn">
                                    <button type="button" class="form-control btn btn-primary dropdown-toggle" style="border-top-right-radius: 3px; border-bottom-right-radius: 3px;"
                                        data-toggle="dropdown">
                                        <span class="caret"></span>
                                    </button>
                                    <ul class="dropdown-menu dropdown-menu-right" role="menu"></ul>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="condition row">
                        <div class="col-sm-3 condition_sm">
                            <label>货品类别</label>
                            <select class="form-control input-w110" id="serarch-type">
                                <option value="">全部</option>
                            </select>
                        </div>
                        <div class="col-sm-3 condition_sm">
                            <label>货品年份</label>
                            <select class="form-control input-w110" id="serarch-year">
                                <option value="">全部</option>
                            </select>
                        </div>
                        <div class="col-sm-3 condition_sm">
                            <label>货品季节</label>
                            <select class="form-control input-w110" id="serarch-season">
                                <option value="">全部</option>
                            </select>
                        </div>
                        <div class="col-sm-3 condition_toggle">
                            <label>货品项目</label>
                            <div class="input-group">
                                <input type="text" class="form-control input-sm" id="serarch-Project">
                                <div class="input-group-btn input-sm thisBtn">
                                    <button type="button" class="form-control btn  btn-primary dropdown-toggle" style="border-top-right-radius: 3px; border-bottom-right-radius: 3px;"
                                        data-toggle="dropdown">
                                        <span class="caret"></span>
                                    </button>
                                    <ul class="dropdown-menu dropdown-menu-right" role="menu"></ul>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="condition row">
                        <div class="col-sm-3 condition_sm">
                            <label class="margin2font">性别</label>
                            <select class="form-control input-w110" id="serarch-Gender">
                                <option value="">全部</option>
                            </select>
                        </div>
                        <div class="col-sm-3 condition_sm">
                            <label>店铺等级</label>
                            <select class="form-control input-w110" id="serarch-level">
                                <option value="">全部</option>
                            </select>
                        </div>
                        <div class="col-sm-3 condition_sm">
                            <label>补货筛选</label>
                            <select class="form-control input-w110" id="serarch-screen">
                                <option value="-1">全部</option>
                                <option value="0">补货需求</option>
                                <option value="1" selected="selected">补货结果</option>
                            </select>
                        </div>
                        <div class="col-sm-3 condition_toggle">
                            <label>&nbsp;&nbsp;&nbsp;子项目&nbsp;</label>
                            <div class="input-group">
                                <input type="text" class="form-control input-sm" id="serarch-ChildProject">
                                <div class="input-group-btn input-sm thisBtn">
                                    <button type="button" class="form-control btn  btn-primary dropdown-toggle" style="border-top-right-radius: 3px; border-bottom-right-radius: 3px;"
                                        data-toggle="dropdown">
                                        <span class="caret"></span>
                                    </button>
                                    <ul class="dropdown-menu dropdown-menu-right" role="menu"></ul>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="condition">
                        <div class="" style="margin-left: 20px; float: left;">
                            <label>店铺</label>
                            <input type="text" class="form-control" style="width: 303px;" id="search-store" />
                        </div>
                        <div class="" style="margin-left: 23px; float: left;">
                            <label>货号</label>
                            <input type="text" class="form-control" style="width: 421px;" id="search-artnum" value="" />
                        </div>
                    </div>
                </div>
                <div class="right-condition">
                    <div class="condition-title">批量维护补货量</div>
                    <div class="condition">
                        <label>系数</label>
                        <div>
                            <input type="number" class="form-control coefficient" style="float: left" />
                            <button type="button" class="btn btn-primary" id="application" style="float: left">应用</button>
                        </div>
                    </div>
                    <table id="batchTable">
                        <thead></thead>
                        <tbody id="batchList"></tbody>
                    </table>
                </div>
                <div class="cb"></div>
            </div>
            <div class="cb" style="overflow: hidden; height: 77px; border-top: 1px solid #999;">
                <div class="leftPart">
                    <table class="leftTable leftTableTitle">
                        <thead></thead>
                    </table>
                </div>
                <div class="rightPart rightTitleScroll">
                    <table class="rightTable">
                        <thead></thead>
                    </table>
                </div>
            </div>

            <div class="cb">
                <div class="leftPart leftScroll" style="overflow-y: hidden;">
                    <table class="leftTable">
                        <tbody id="leftList"></tbody>
                    </table>
                </div>
                <div class="rightPart rightScroll">
                    <table class="rightTable">
                        <tbody id="rightList"></tbody>
                    </table>
                </div>
            </div>

            <div class="pageControl"></div>
        </div>
    </div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="footer" runat="Server">
    <script src="../assets/js/framework.js"></script>
    <script src="../assets/js/page/pageControl.js"></script>
    <script src="../assets/js/page/tableControl.js"></script>
    <script src="../assets/js/plugins/bootstrap-suggest/bootstrap-suggest.min.js"></script>
    <script src="../assets/js/plugins/bootstrap-suggest/itemSuggest.js"></script>
    <script>
        $(document).ready(function () {
            //自动收缩左边菜单栏
            commonUtil.autoLeftWidth();
            //$('.navbar-minimalize i', window.parent.document).click();
            //计算表格高度
            var sUserAgent = navigator.userAgent.toLowerCase();
            var changeTableHeight = function () {
                if (sUserAgent.indexOf('chrome') > -1) {
                    $('.leftScroll').css({ height: ($('.right-side').height() - $('.condition-container').outerHeight() - 146) + 'px' });
                    $('.rightScroll').css({ height: ($('.leftScroll').height() + 6) + 'px' });
                    $('.rightScroll').css({ width: ($('.rightTitleScroll').width() + 6) + 'px' });
                } else {
                    $('.leftScroll').css({ height: ($('.right-side').height() - $('.condition-container').outerHeight() - 160) + 'px' });
                    $('.rightScroll').css({ height: ($('.leftScroll').height() + 17) + 'px' });
                    //$('.rightScroll').css({ width: ($('.rightTitleScroll').width() + 17) + 'px' });
                    $('.rightScroll').css({ width: ($('.rightTitleScroll').width()) + 'px' });
                }
            }
            changeTableHeight();
            $(window).resize(function () {
                changeTableHeight();
            })

            //右表格滚动事件
            $('.rightScroll').scroll(function () {
                $('.leftScroll').scrollTop($('.rightScroll').scrollTop());
                $('.rightTitleScroll').scrollLeft($('.rightScroll').scrollLeft());
                $('.rightScroll').scrollLeft($('.rightTitleScroll').scrollLeft());
            })

            //模块ID
            var ModuleID = Y.getUrlParam("ModuleID");
            //页数
            var page = 1;
            //获取按钮
            commonUtil.loadBtnList(ModuleID, function () {
                $('.btns-container').append('<div style="clear: both;"></div>');
            });

            //绑定发货仓库
            commonUtil.bindOdsErpBasStocks({ StockID: 'StockID' }, ['#serarch-warehouse']);

            //绑定省市
            var provinceList = [];
            $('#serarch-warehouse').change(function () {
                provinceList = [];
                $('#serarch-province').empty();
                $('#serarch-province').append('<option value="">请选择</option>');
                $('#serarch-city').empty();
                $('#serarch-city').append('<option value="">请选择</option>');
                if ($(this).val() == '')
                    return false;
                Y.API2('OdsErpBasArea', 'GetOdsErpBasAreaList', {
                    Param: 2,
                    DistrictID: $('#serarch-warehouse').val()
                }, function (data) {
                    if (data.Success == false) {
                        swal(data.Message, '', 'error');
                    } else {
                        data.map(function (item) {
                            provinceList.push(item);
                            $('#serarch-province').append('<option value="' + item[0].ParentID + '">' + item[0].ParentName + '</option>');
                        })
                    }
                })
            })

            //货品类别
            Y.API3('DWSuppleAllMessage', 'GetErpSDMatKindList', {}, function (data) {
                if (data.Success == false) {
                    layer.closeAll('dialog');
                    swal(data.Message, '', 'error');
                } else {
                    data.map(function (item) {
                        $('#serarch-type').append('<option value="' + item.KindID + '">' + item.KindName + '</option>');
                    })
                }
            })

            //货品款型
            //Y.API3('DWSuppleAllMessage', 'GetOdsErpSDMatModel', {}, function (data) {
            //    if (data.Success == false) {
            //        layer.closeAll('dialog');
            //        swal(data.Message, '', 'error');
            //    } else {
            //        data.map(function (item) {
            //            $('#serarch-style').append('<option value="' + item.ModelID + '">' + item.ModelName + '</option>');
            //        })
            //    }
            //});
            //货品款型
            var itemSuggest1 = new itemSuggest();
            itemSuggest1.initSuggest('serarch-style', 'DWSuppleAllMessage', 'GetOdsErpSDMatModel', 'ModelName', 'ModelName');
            //var items = itemSuggest1.getSelectIds();


            //选择省份
            $('#serarch-province').change(function () {
                $('#serarch-city').empty();
                $('#serarch-city').append('<option value="">请选择</option>');
                var $this = $(this);
                provinceList.map(function (item) {
                    if (item[0].ParentID == $this.val()) {
                        item.map(function (city) {
                            $('#serarch-city').append('<option value="' + city.AreaID + '">' + city.AreaName + '</option>');
                        });
                        $('#serarch-city').val('');
                        return false;
                    }
                });
            });

            //货品项目数据源
            var initSuggestPram1 = new itemSuggest();
            var obj = { Types: "Project" };
            initSuggestPram1.initSuggestPram('serarch-Project', 'DWSuppleAllMessage', 'GetSelectList', 'ItemName', 'ItemName', obj);

            //子项目数据源
            var initSuggestPram2 = new itemSuggest();
            obj = { Types: "ChildProject" };
            initSuggestPram2.initSuggestPram('serarch-ChildProject', 'DWSuppleAllMessage', 'GetSelectList', 'SubItem', 'SubItem', obj);

            // 性别数据源
            Y.API3('DWSuppleAllMessage', 'GetSelectList', { Types: "Gender" }, function (data) {
                if (data.Success == false) {
                    layer.closeAll('dialog');
                    swal(data.Message, '', 'error');
                } else {
                    data.map(function (item) {
                        $('#serarch-Gender').append('<option value="' + item.SexName + '">' + item.SexName + '</option>');
                    })
                }
            });


            //年份
            commonUtil.bindDwGlobalVariables({ dictValue: '年份' }, ['#serarch-year']);
            //季节
            commonUtil.bindDwGlobalVariables({ dictValue: '季节' }, ['#serarch-season']);

            //店铺等级

            Y.API2('DwShop', 'GetShopAndCustBaseInfo', { InfoType: 'ShopLevel' }, function (data) {
                if (data.Success == false) {
                    layer.closeAll('dialog');
                    swal(data.Message, '', 'error');
                } else {
                    data.map(function (item) {
                        $('#serarch-level').append('<option value="' + item.InfoName + '">' + item.InfoName + '</option>');
                    })
                }
            })

            //处理表头（批量）
            tableControl.initThead('#batchTable', [{
                trClass: '', children: [
                    { tdText: '', c: 0, r: 0, tdHtml: '<input type="checkbox" id="checkAllBatch" />', tdId: '', tdClass: '' },
                    { tdText: '尺码', c: 0, r: 0, tdHtml: '', tdId: '', tdClass: '' },
                    { tdText: '库存数量', c: 0, r: 0, tdHtml: '', tdId: '', tdClass: '' },
                    { tdText: '补货占用量', c: 0, r: 0, tdHtml: '', tdId: '', tdClass: '' },
                    { tdText: '剩余数量', c: 0, r: 0, tdHtml: '', tdId: '', tdClass: '' }
                ]
            }])

            //处理表头（左）
            tableControl.initThead('.leftTable',
                [
                    {
                        trClass: '',
                        children: [
                            {
                                tdText: '',
                                c: 0,
                                r: 3,
                                tdHtml:
                                '<span style="display:inline-block; width:24px;"><input type="checkbox" id="checkAll" /></span>',
                                tdId: '',
                                tdClass: 'td-w24 td-h76'
                            },
                            {
                                tdText: '',
                                c: 0,
                                r: 3,
                                tdHtml: '<span style="display:inline-block; width:62px;">仓库</span>',
                                tdId: '',
                                tdClass: 'td-w62 td-h76'
                            },
                            {
                                tdText: '',
                                c: 0,
                                r: 3,
                                tdHtml: '<span style="display:inline-block; width:170px;">店铺名称</span>',
                                tdId: '',
                                tdClass: 'td-w170 td-h76'
                            },
                            {
                                tdText: '',
                                c: 0,
                                r: 3,
                                tdHtml: '<span style="display:inline-block; width:120px;">货号</span>',
                                tdId: '',
                                tdClass: 'td-w120 td-h76'
                            },
                            //货品简称 零售价   性别
                            { tdText: '', c: 0, r: 3, tdHtml: '<span style="display:inline-block; width:170px;">货品简称</span>', tdId: '', tdClass: 'td-w170 td-h76' },
                            { tdText: '', c: 0, r: 3, tdHtml: '<span style="display:inline-block; width:56px;">零售价</span>', tdId: '', tdClass: 'td-w56 td-h76' },
                            { tdText: '', c: 0, r: 3, tdHtml: '<span style="display:inline-block; width:56px;">性别</span>', tdId: '', tdClass: 'td-w56 td-h76' },
                            { tdText: '', c: 0, r: 3, tdHtml: '<span style="display:inline-block; width:56px;">中包装</span>', tdId: '', tdClass: 'td-w56 td-h76' },
                            //      	{tdText: '货品简称', c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'td-w90' },
                            //      	{tdText: '款型', c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'td-w90' },
                            {
                                tdText: '',
                                c: 0,
                                r: 3,
                                //tdHtml: '<span style="display:inline-block; width:56px;">SKC畅滞销状态</span>',
                                tdHtml: '<span style="display:inline-block; width:56px;">SKC近一周畅滞销状态</span>',
                                tdId: '',
                                tdClass: 'td-w56'
                            },
                            //      	{tdText: '补货间隔', c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'td-w62' },
                            //          {tdText: '作业+物流天数', c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'td-w56' },
                            //          {tdText: '销售开始日期', c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'td-w72' },
                            //          {tdText: '销售结束日期', c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'td-w72' },
                            {
                                tdText: '',
                                c: 0,
                                r: 3,
                                tdHtml: '<span style="display:inline-block; width:30px;">码段分类</span>',
                                tdId: '',
                                tdClass: 'td-w30 td-h76'
                            },
                            {
                                tdText: '',
                                c: 0,
                                r: 0,
                                tdHtml: '<span style="display:inline-block; width:30px;">01</span>',
                                tdId: '',
                                tdClass: 'td-w30 td-h39'
                            },
                        ]
                    },
                    {
                        trClass: '',
                        children: [
                            {
                                tdText: '',
                                c: 0,
                                r: 0,
                                tdHtml: '<span style="display:inline-block; width:30px;">02</span>',
                                tdId: '',
                                tdClass: 'td-w30'
                            },
                        ]
                    },
                    {
                        trClass: '',
                        children: [
                            {
                                tdText: '',
                                c: 0,
                                r: 0,
                                tdHtml: '<span style="display:inline-block; width:30px;">03</span>',
                                tdId: '',
                                tdClass: 'td-w30'
                            },
                        ]
                    },
                ]);

            //处理表头（右）
            var partCount = 4;	//4部分
            var arr01 = ['01'];//['01', 'F', 'XS', 'S', 'M', 'L', 'XL', 'XXL', '3XL', 'XXS', '', '', ''];					
            var arr02 = ['02'];//['02', '25','26','27', '28', '29', '30', '31', '32', '33', '34', '35','36'];									
            var arr03 = ['03'];//['03', '37', '38', '39', '40', '41', '42', '43', '44', '45', '', '',  '合计'];
            var children01 = [];
            var children02 = [];
            var children03 = [];
            //动态获取尺码内容  guweihua 2017.10.30
            Y.API3('DWSuppleAllMessage', 'GetSizeTextTypeList', {}, function (data) {
                if (data.Success != false) {
                    arr01.splice(1, arr01.length);
                    arr02.splice(1, arr02.length);
                    arr03.splice(1, arr03.length);
                    //将值放入数组
                    for (var i = 0; i < data.length; i++) {
                        if (data[i].SizeTypeCode == '01') {
                            arr01.push(data[i].SizeName);
                        }
                        else if (data[i].SizeTypeCode == '02') {
                            arr02.push(data[i].SizeName);
                        }
                        else if (data[i].SizeTypeCode == '03') {
                            arr03.push(data[i].SizeName);
                        }
                    }
                    //13个为一行，不足的用空格补上
                    for (var i = 0; i <= 13; i++) {
                        if (arr01.length <= 13)
                            arr01.push('');
                        if (arr02.length <= 13)
                            arr02.push('');
                        if (arr03.length <= 12)
                            arr03.push('');
                    }
                    arr03.push('合计');//补上合计文字
                }
            });

            //fstBorder是为了隔开不同的模块加粗线
            for (var i = 0; i < partCount; i++) {
                if (i == 0) {
                    arr01.map(function (item, j) {
                        if (j == 0)
                            children01.push({ tdText: item, c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'td-noTop-border hide' });
                        else
                            children01.push({ tdText: item, c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'SevenDay' });
                    });
                    arr02.map(function (item, j) {
                        var isFst = false;
                        if (item == 'F' || item == '34' || item == '25')
                            isFst = true;
                        if (j == 0)
                            children02.push({ tdText: item, c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'hide' });
                        else
                            children02.push({ tdText: item, c: 0, r: 0, tdHtml: '', tdId: '', tdClass: (isFst && i != 0 ? 'fstBorder SevenDay' : 'SevenDay') });
                    });
                    arr03.map(function (item, j) {
                        var isFst = false;
                        if (item == 'F' || item == '34' || item == '25')
                            isFst = true;
                        if (j == 0)
                            children03.push({ tdText: item, c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'hide' });
                        else
                            children03.push({ tdText: item, c: 0, r: 0, tdHtml: '', tdId: '', tdClass: (isFst && i != 0 ? 'fstBorder SevenDay' : 'SevenDay') });
                    });
                } else {
                    arr01.map(function (item, j) {
                        if (j != 0) {
                            var isFst = false;
                            if (item == 'F' || item == '34' || item == '25')
                                isFst = true;

                            if (j == 0)
                                children01.push({ tdText: item, c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'hide' });
                            else
                                children01.push({ tdText: item, c: 0, r: 0, tdHtml: '', tdId: '', tdClass: (isFst && i != 0 ? 'fstBorder' : '') });
                        }
                    });
                    arr02.map(function (item, j) {
                        if (j != 0) {
                            var isFst = false;
                            if (item == 'F' || item == '34' || item == '25')
                                isFst = true;

                            if (j == 0)
                                children02.push({ tdText: item, c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'hide' });
                            else
                                children02.push({ tdText: item, c: 0, r: 0, tdHtml: '', tdId: '', tdClass: (isFst && i != 0 ? 'fstBorder' : '') });
                        }
                    });
                    arr03.map(function (item, j) {
                        if (j != 0) {
                            var isFst = false;
                            if (item == 'F' || item == '34' || item == '25')
                                isFst = true;

                            if (j == 0)
                                children03.push({ tdText: item, c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'hide' });
                            else
                                children03.push({ tdText: item, c: 0, r: 0, tdHtml: '', tdId: '', tdClass: (isFst && i != 0 ? 'fstBorder' : '') });
                        }
                    });
                }
            }

            tableControl.initThead('.rightTable', [
                {
                    trClass: '', children: [
                        { tdText: '码段分类', c: 0, r: 4, tdHtml: '', tdId: '', tdClass: 'td-w28 td-break hide' },
                        { tdText: '', c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'hide' },
                        { tdText: '近七个有效日日均销售量', c: 13, r: 0, tdHtml: '', tdId: '', tdClass: '' },
                        { tdText: '补货量', c: 13, r: 0, tdHtml: '', tdId: '', tdClass: 'fstBorder replenishment' },
                        { tdText: '在仓库存+在途库存+订单在途', c: 13, r: 0, tdHtml: '', tdId: '', tdClass: 'fstBorder' },
                        { tdText: '补货后', c: 13, r: 0, tdHtml: '', tdId: '', tdClass: 'fstBorder' },
                    ]
                },
                { trClass: '', children: children01 },
                { trClass: '', children: children02 },
                { trClass: '', children: children03 },
            ])

            //无数据处理
            var dealNull = function () {
                var tempChild = [];
                var tempChild2 = [];
                var tempLeftWidth = 0;
                var tempRightWidth = $('.rightTable:first thead tr').eq(1).children().size() * 30;
                $('.leftTableTitle thead tr:first').children().each(function (index) {
                    if (index != 0)
                        tempLeftWidth += $(this).find('span').width();
                })
                tempChild.push({ tdText: '', c: 0, r: 0, tdHtml: '<span style="display:inline-block; width:23px;"><i class="fa fa-frown-o"></i></span>', tdId: '', tdClass: '' });
                tempChild.push({ tdText: '', c: 0, r: 0, tdHtml: '<span style="display:inline-block; width:' + tempLeftWidth + 'px">暂无数据</span>', tdId: '', tdClass: 'td-noRight-border' });
                var tempTr = { trClass: '', children: tempChild };
                tableControl.initTbody('.leftTable', [tempTr], 0, null);
                tempChild2.push({ tdText: ' ', c: 0, r: 0, tdHtml: '<span style="display:inline-block; width:' + (tempRightWidth - 6) + 'px"></span>', tdId: '', tdClass: '' });
                tempTr = { trClass: '', children: tempChild2 };
                tableControl.initTbody('.rightTable', [tempTr], 0, null);
                $('.rightScroll tbody td').css({ maxWidth: (tempRightWidth - 6) + 'px' });
            }
            dealNull();

            //右表格相关数据计算
            var calcRightTb = function () {
                $('#rightList tr').each(function () {
                    var $this = $(this);
                    //计算第1部分的合计
                    var count = 0;
                    $($this.find('.td-bg-style1')).each(function (index) {
                        if (index < $this.find('.td-bg-style1').size() - 1)
                            count += (isNaN(parseFloat($(this).text())) ? 0 : parseFloat($(this).text()));
                    })
                    $this.find('.td-bg-style1:last').text(count.toFixed(1));
                    $this.find('.td-bg-style1:last').attr('title', count.toFixed(1));
                    //计算第2部分的合计
                    count = 0;
                    $($this.find('.td-bg-style2')).each(function (index) {
                        var tempValue = $(this).find('.setnum').size() > 0 ? parseFloat($(this).find('.setnum').val()) : parseFloat($(this).text());
                        if (index < $this.find('.td-bg-style2').size() - 1)
                            count += (isNaN(tempValue) ? 0 : tempValue);
                    })
                    $this.find('.td-bg-style2:last').text(count);
                    $this.find('.td-bg-style2:last').attr('title', count);
                    //计算第3部分的合计
                    count = 0;
                    $($this.find('.td-bg-style3')).each(function (index) {
                        if (index < $this.find('.td-bg-style3').size() - 1)
                            count += (isNaN(parseFloat($(this).text())) ? 0 : parseFloat($(this).text()));
                    })
                    $this.find('.td-bg-style3:last').text(count);
                    $this.find('.td-bg-style3:last').attr('title', count);

                    //计算第4部分
                    count = 0;
                    $($this.find('.td-bg-style4')).each(function (index) {
                        var tempValue2 = 0;
                        if ($this.find('.td-bg-style2').eq(index).find('.setnum').size() > 0)
                            tempValue2 = parseFloat($this.find('.td-bg-style2').eq(index).find('.setnum').val());
                        else
                            tempValue2 = parseFloat($this.find('.td-bg-style2').eq(index).text());
                        tempValue2 = isNaN(tempValue2) ? 0 : tempValue2;
                        var tempValue3 = parseFloat($this.find('.td-bg-style3').eq(index).text());
                        tempValue3 = isNaN(tempValue3) ? 0 : tempValue3;
                        tempValue4 = tempValue2 + tempValue3;
                        if (index == $this.find('.td-bg-style4').size() - 1) {
                            $(this).text(tempValue4);
                        } else {
                            $(this).text((isNaN(tempValue4) || tempValue4 == 0 ? '' : tempValue4));
                        }
                        if (index < $this.find('.td-bg-style4').size() - 1)
                            count += (isNaN(parseFloat($(this).text())) ? 0 : parseFloat($(this).text()));
                    })
                    $this.find('.td-bg-style4:last').text(count);
                    $this.find('.td-bg-style4:last').attr('title', count);

                    //样式整理
                    $this.find('.td-bg-style2:first').addClass('fstBorder');
                    $this.find('.td-bg-style3:first').addClass('fstBorder');
                    $this.find('.td-bg-style4:first').addClass('fstBorder');
                })
            }

            //计算批量维护表
            var maintainCount = function () {
                $('#btn-save').removeAttr('disabled');
                $('#batchList tr').each(function () {
                    var $this = $(this);
                    var count = parseInt($this.find('.CanUseQty').text()) - parseInt($this.find('.Taken').text());
                    $this.find('.Remain').text(count);
                    $this.find('.Remain').css({ color: '' });
                    if (count < 0) {
                        $this.find('.Remain').css({ color: '#f00' });
                        $('#btn-save').attr('disabled', 'disabled');
                    }
                })
            }

            var loadMainList = function (hasArtnum) {
                auxiliaryList = [];
                $('.replenishment').text('补货量');
                var KindName = $("#serarch-type").val() == '' ? '' : $("#serarch-type").find("option:selected").text();
                //var ModelName = $("#serarch-style").val() == '' ? '' : $("#serarch-style").find("option:selected").text();
                pageControl.init('DWSuppleAllMessage', 'GetDWSuppleAllMessageList', {
                    FHStockID: $('#serarch-warehouse').val(),
                    ShopKeys: $('#search-store').val().trim(),
                    ProID: $('#serarch-province').val(),
                    CityID: $('#serarch-city').val(),
                    ShopLevelCode: $('#serarch-level').val(),
                    MaterialID: $('#search-artnum').val().trim(),
                    YearNo: $('#serarch-year').val(),
                    SeasonName: $('#serarch-season').val(),
                    KindName: KindName,
                    ModelName: itemSuggest1.getSelectIds(),// ModelName,
                    SuppleQty: $('#serarch-screen').val(),
                    Page: page,
                    Project: initSuggestPram2.getSelectIds(),// //$("#serarch-Project").val(),
                    Gender: $("#serarch-Gender").val(),
                    ChildProject: initSuggestPram1.getSelectIds(),// $("#serarch-ChildProject").val(),
                    //			Size: 100,
                    needLayer: true,
                    alwaysCallBack: function () {
                        $('#leftList').empty();
                        $('#rightList').empty();
                        Y.API2('DWSuppleAllMessage', 'TotalDWSuppleAllMessageList', {
                            FHStockID: $('#serarch-warehouse').val(),
                        }, function (ds) {
                            if (ds.Success == false)
                                swal(ds.Message, '', 'error');
                            else
                                $('.replenishment').text('补货量（' + ds + '）');
                        })
                    }
                }, function (result) {
                    page = result.page;
                    var tBody1 = [];
                    var tBody2 = [];
                    if (!Y.checkNull(result.data)) {
                        if (result.data.Items.length > 0) {
                            auxiliaryList = result.data.Items;
                            result.data.Items.map(function (item, i) {
                                //处理左表格
                                var tempTr = {
                                    trClass: '',
                                    children: [
                                        { tdText: '', c: 0, r: 0, tdHtml: '<input type="checkbox" class="checkItem" />', tdId: '', tdClass: 'td-w24' },
                                        { tdText: item[0].FHStockName, c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'td-w62' },
                                        { tdText: '', c: 0, r: 0, tdHtml: '<span class="auxiliaryText" data-toggle="modal" data-target="#auxiliary">' + item[0].ShopName + '</span>', tdId: '', tdClass: 'td-w170' },
                                        { tdText: item[0].MaterialCode, c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'td-w120' + (item[0].isModify ? ' modifyColor' : '') },

                                        //货品简称 零售价   性别 中包装 MaterialShortName,sam.RetailPrice,sam.SexName,sam.SizeLimit
                                        { tdText: item[0].MaterialShortName, c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'td-w170' },
                                        { tdText: item[0].RetailPrice == null ? "" : item[0].RetailPrice, c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'td-w56' },
                                        { tdText: item[0].SexName == null ? "" : item[0].SexName, c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'td-w56' },
                                        { tdText: item[0].SizeLimit == null ? "" : item[0].SizeLimit, c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'td-w56' },


                                        //								{tdText:item[0].MaterialShortName, c:0 , r:0, tdHtml:'', tdId:'', tdClass:'td-w90'},
                                        //								{tdText:item[0].ModelName, c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'td-w90'},
                                        { tdText: item[0].SKCCzpFlag, c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'td-w56' },
                                        //								{tdText:item[0].ReplenishDay, c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'td-w62'},
                                        //								{tdText:item[0].BTDays, c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'td-w56'},
                                        //								{tdText:item[0].SaleBgDate, c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'td-w72'},
                                        //								{tdText:item[0].SaleEnddate, c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'td-w72'},
                                        { tdText: item[0].SizeTypeCode, c: 2, r: 0, tdHtml: '', tdId: '', tdClass: 'td-w60' },
                                    ]
                                };
                                tBody1.push(tempTr);

                                //处理右表格
                                var tempChild = [];
                                tempChild.push({ tdText: item[0].SizeTypeCode, c: 2, r: 0, tdHtml: '', tdId: '', tdClass: 'hide' });

                                var rowIndex = 1;
                                switch (item[0].SizeTypeCode) {
                                    case '02':
                                        rowIndex = 2;
                                        break;
                                    case '03':
                                        rowIndex = 3;
                                        break;
                                    case '01':
                                        rowIndex = 1;
                                        break;
                                    default:
                                        break;
                                }

                                $('.rightTable thead tr').eq(rowIndex).children().each(function (index) {
                                    var $this = $(this);
                                    var count = 0;
                                    if (index > 0) {

                                        item.map(function (it) {
                                            it.EndQty = Y.checkNull(it.EndQty) ? 0 : it.EndQty;
                                            it.PathQty = Y.checkNull(it.PathQty) ? 0 : it.PathQty;
                                            it.OrderPathQty = Y.checkNull(it.OrderPathQty) ? 0 : it.OrderPathQty;
                                            it.UpdateSuppleQty = Y.checkNull(it.UpdateSuppleQty) ? 0 : it.UpdateSuppleQty;
                                            //第1部分
                                            if (it.SizeName == $this.text() && index < 13 && tempChild.length <= 13) {
                                                tempChild.push({ tdText: (Y.checkNull(it.AvgWeekSaleQty) ? '' : it.AvgWeekSaleQty.toFixed(1)), c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'td-bg-style1 SevenDay' });
                                                return;
                                                //第2部分
                                            } else if (it.SizeName == $this.text() && index >= 14 && index < 26 && tempChild.length <= 26) {
                                                //是否合计
                                                if (index != 26) {
                                                    //判断是否带货号查询
                                                    if (hasArtnum && $('#batchList tr').size() > 0) {
                                                        var countBatch = 0;
                                                        $('#batchList tr').each(function () {
                                                            if ($(this).find('.SizeName').text().trim() == it.SizeName.trim()) {
                                                                tempChild.push({ tdText: '', c: 0, r: 0, tdHtml: '<input type="number" class="setnum ' + it.SizeID + ' ' + $(this).find('.SizeName').text().trim() + '" value="' + (it.UpdateSuppleQty == 0 ? '' : it.UpdateSuppleQty) + '" />', tdId: '', tdClass: 'td-bg-style2  td-bg-style5' });
                                                                return false;
                                                            }
                                                            countBatch++;
                                                        })
                                                        if (countBatch == $('#batchList tr').size())
                                                            tempChild.push({ tdText: (it.UpdateSuppleQty == 0 ? '' : it.UpdateSuppleQty), c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'td-bg-style2' });
                                                    } else {
                                                        tempChild.push({ tdText: (it.UpdateSuppleQty == 0 ? '' : it.UpdateSuppleQty), c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'td-bg-style2' });
                                                    }
                                                } else {
                                                    tempChild.push({ tdText: '', c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'td-bg-style2' });
                                                }
                                                return;
                                                //第3部分
                                            } else if (it.SizeName == $this.text() && index >= 27 && index < 39 && tempChild.length <= 39) {
                                                tempChild.push({ tdText: (it.EndQty + it.PathQty + it.OrderPathQty == 0 ? '' : it.EndQty + it.PathQty + it.OrderPathQty), c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'td-bg-style3' });
                                                return;
                                                //第4部分
                                            } else if (it.SizeName == $this.text() && index >= 40 && index < 52 && tempChild.length <= 52) {
                                                tempChild.push({ tdText: (it.UpdateSuppleQty + it.EndQty + it.PathQty + it.OrderPathQty == 0 ? '' : it.UpdateSuppleQty + it.EndQty + it.PathQty + it.OrderPathQty), c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'td-bg-style4' });
                                                return;
                                            }
                                            count++;

                                        })
                                        if (count == item.length) {
                                            if (index <= 13 && tempChild.length <= 13) {
                                                tempChild.push({ tdText: '', c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'td-bg-style1 SevenDay' });
                                                return;
                                            } else if (index >= 14 && index <= 26 && tempChild.length <= 26) {
                                                //是否合计
                                                if (index != 26) {
                                                    //判断是否带货号查询
                                                    if (hasArtnum && $('#batchList tr').size() > 0) {
                                                        var countBatch = 0;
                                                        $('#batchList tr').each(function () {
                                                            if ($(this).find('.SizeName').text().trim() == $this.text().trim()) {
                                                                tempChild.push({ tdText: '', c: 0, r: 0, tdHtml: '<input type="number" class="setnum ' + $(this).find('.hide.SizeID').text().trim() + ' ' + $(this).find('.SizeName').text().trim() + '" value="" />', tdId: '', tdClass: 'td-bg-style2  td-bg-style5' });
                                                                return false;
                                                            }
                                                            countBatch++;
                                                        })
                                                        if (countBatch == $('#batchList tr').size())
                                                            tempChild.push({ tdText: '', c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'td-bg-style2' });
                                                    } else {
                                                        tempChild.push({ tdText: '', c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'td-bg-style2' });
                                                    }
                                                } else {
                                                    tempChild.push({ tdText: '', c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'td-bg-style2' });
                                                }
                                                return;
                                            } else if (index >= 27 && index <= 39 && tempChild.length <= 39) {
                                                tempChild.push({ tdText: '', c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'td-bg-style3' });
                                                return;
                                            } else if (index >= 40 & index <= 52 && tempChild.length <= 52) {
                                                tempChild.push({ tdText: '', c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'td-bg-style4' });
                                                return;
                                            }

                                        }
                                    }
                                })

                                tempTr = {
                                    trClass: '',
                                    children: tempChild
                                }
                                tBody2.push(tempTr)
                            })
                            //左表信息处理
                            tableControl.initTbody('.leftTable', (tBody1.length > 0 ? tBody1 : null), 0, null);
                            //右表信息处理
                            tableControl.initTbody('.rightTable', (tBody2.length > 0 ? tBody2 : null), 0, null);
                            calcRightTb();


                        } else {
                            //无数据处理
                            dealNull();
                        }
                        changeTableHeight();
                    }
                });

            }

            var auxiliaryList = [];
            var skcList = [];
            var loadList = function () {
                if ($('#serarch-warehouse').val() == '') {
                    swal('请选择发货仓库');
                    return false;
                }
                var tBody3 = [];
                skcList = [];
                $('#batchList').empty();
                //处理SKC列表
                if ($('#search-artnum').val().trim() != '') {
                    layer.msg('玩命加载中……', { icon: 16, shade: 0.5, time: 0, maxWidth: 200 });
                    Y.API2('DWSuppleAllMessage', 'GetDWFHStockCanUseList', {
                        FHStockID: $('#serarch-warehouse').val(),
                        MaterialID: $('#search-artnum').val().trim(),
                    }, function (data) {
                        layer.closeAll('dialog');
                        if (data.Success == false) {
                            swal(data.Message, '', 'error');
                        } else {
                            if (data && data.length > 0) {
                                skcList = data[0];
                                data[0].map(function (item) {
                                    var tempTr = {
                                        trClass: (i % 2 == 0 ? 'gradeX footable-even' : 'gradeX footable-odd'),
                                        children: [
                                            { tdText: item.FHStockID, c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'hide FHStockID' },
                                            { tdText: item.MaterialID, c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'hide MaterialID' },
                                            { tdText: item.SizeID, c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'hide SizeID ' + item.SizeID },
                                            { tdText: '', c: 0, r: 0, tdHtml: '<input type="checkbox" class="checkBatch" />', tdId: '', tdClass: '' },
                                            { tdText: item.SizeName, c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'SizeName' },
                                            { tdText: item.CanUseQty, c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'CanUseQty' },
                                            { tdText: item.Taken, c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'Taken' },
                                            { tdText: '', c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'Remain' },
                                        ]
                                    };
                                    tBody3.push(tempTr);
                                })
                                tableControl.initTbody('#batchTable', (tBody3.length > 0 ? tBody3 : null), 5, null);
                                maintainCount();
                            }
                            loadMainList(true);
                        }
                    })
                } else {
                    loadMainList(false);
                }

            }

            //修改补货量
            $('#rightList').on('blur', '.setnum', function () {
                var trIndex = $(this).parents('tr').index();
                var TempValue = parseInt($(this).val());
                if (!isNaN(TempValue)) {
                    if (TempValue < 0)
                        TempValue = 0;
                } else {
                    TempValue = '';
                }
                $(this).val(TempValue);
                calcRightTb();
                var className = $(this).attr('class').split(' ')[1];
                var takenValue = '';
                var auxiliaryValue = 0;
                var inputValue = 0;
                auxiliaryList.map(function (item) {
                    item.map(function (it) {
                        if (it.SizeID == className) {
                            auxiliaryValue += parseInt(it.UpdateSuppleQty);
                        }
                    })
                })
                skcList.map(function (item) {
                    if (item.SizeID == className) {
                        takenValue = item.Taken;
                    }
                })

                auxiliaryValue = auxiliaryValue == '' ? 0 : auxiliaryValue;
                $('#rightList tr').each(function () {
                    inputValue += parseInt(Y.checkNull($(this).find('.setnum.' + className).val()) ? 0 : $(this).find('.setnum.' + className).val());
                })
                var t = parseInt(auxiliaryValue) - parseInt(inputValue);
                var final = parseInt(takenValue) - parseInt(t);
                var taken = $(".hide.SizeID." + className).parents('tr').find('.Taken').text(final);
                maintainCount();
            })

            //查询按钮
            $('.btns-container').on('click', '#btn-search', function () {
                page = 1;
                loadList();
            });

            //下载按钮
            $(".btns-container").on("click", '#downloadAllocation', function () {
                if ($('#serarch-warehouse').val() == '') {
                    swal('请选择发货仓库');
                    return false;
                }
                var conditionsArr = [];
                var KindName = $("#serarch-type").val() == '' ? '' : $("#serarch-type").find("option:selected").text();
                var ModelName = $("#serarch-style").val() == '' ? '' : $("#serarch-style").find("option:selected").text();
                conditionsArr.push({ column: "sam.FHStockID", value: $('#serarch-warehouse').val(), operator: "=", connector: "and" });
                conditionsArr.push({ column: "eba.ParentID", value: $('#serarch-province').val(), operator: "=", connector: "and" });
                conditionsArr.push({ column: "ds.AreaID", value: $('#serarch-city').val(), operator: "=", connector: "and" });
                conditionsArr.push({ column: "ds.ShopName", value: $('#search-store').val(), operator: "like", connector: "and" });
                conditionsArr.push({ column: "sam.KindName", value: KindName, operator: "=", connector: "and" });
                conditionsArr.push({ column: "sam.YearNo", value: $('#serarch-year').val(), operator: "=", connector: "and" });
                conditionsArr.push({ column: "sam.SeasonName", value: $('#serarch-season').val(), operator: "=", connector: "and" });
                conditionsArr.push({ column: "sam.MaterialID", value: $('#search-artnum').val(), operator: "=", connector: "and" });
                conditionsArr.push({ column: "sam.ModelName", value: ModelName, operator: "=", connector: "and" });
                //      if(parseInt($('#serarch-screen').val()) ==1){
                //          conditionsArr.push({ column: "sam.SuppleQty", value: 0, operator: ">", connector: "and" });
                //      }else{	
                //          conditionsArr.push({ column: "sam.SuppleQty", value: 0, operator: "<=", connector: "and" });
                //      }
                conditionsArr.push({ column: "dw.ShopLevelCode", value: $('#serarch-level').val(), operator: "=", connector: "and" });
                conditionsArr = JSON.stringify(conditionsArr);
                //      //如果不是选中的所有尺码，就筛选尺码
                //      if ($('#search-size-name').val().length > 0) {
                //          conditionsArr.push("SizeName:" + $('#search-size-name').val());
                //      }   
                //conditionsArr.push("Page:" + page);
                $.Export({
                    filetype: 'replenishment',
                    filename: '智能补货结果',
                    conditions: encodeURIComponent(conditionsArr),
                    after: function () {
                        //回调方法
                        //loadList(1);
                        swal("导出成功!");
                    }
                });
            });

            //导出SKC畅滞销状态
            $(".btns-container").on("click", '#downloadSKC', function () {
                var conditionsArr = [];
                var KindName = $("#serarch-type").val() == '' ? '' : $("#serarch-type").find("option:selected").text();
                var ModelName = $("#serarch-style").val() == '' ? '' : $("#serarch-style").find("option:selected").text();
                conditionsArr.push({ column: "sam.FHStockID", value: $('#serarch-warehouse').val(), operator: "=", connector: "and" });
                conditionsArr.push({ column: "eba.ParentID", value: $('#serarch-province').val(), operator: "=", connector: "and" });
                conditionsArr.push({ column: "ds.AreaID", value: $('#serarch-city').val(), operator: "=", connector: "and" });
                conditionsArr.push({ column: "ds.ShopName", value: $('#search-store').val(), operator: "like", connector: "and" });
                conditionsArr.push({ column: "sam.KindName", value: KindName, operator: "=", connector: "and" });
                conditionsArr.push({ column: "sam.YearNo", value: $('#serarch-year').val(), operator: "=", connector: "and" });
                conditionsArr.push({ column: "sam.SeasonName", value: $('#serarch-season').val(), operator: "=", connector: "and" });
                conditionsArr.push({ column: "sam.MaterialID", value: $('#search-artnum').val(), operator: "=", connector: "and" });
                conditionsArr.push({ column: "sam.ModelName", value: ModelName, operator: "=", connector: "and" });
                conditionsArr.push({ column: "dw.ShopLevelCode", value: $('#serarch-level').val(), operator: "=", connector: "and" });
                conditionsArr = JSON.stringify(conditionsArr);
                $.Export({
                    filetype: 'STATESKC',
                    //filename: 'SKC畅滞销状态',
                    filename: 'SKC近一周畅滞销状态',
                    conditions: encodeURIComponent(conditionsArr),
                    after: function () {
                        //回调方法
                        //loadList(1);
                        swal("导出成功!");
                    }
                });
            });

            //导出辅助数据
            $(".btns-container").on("click", '#downloadAuxiliary', function () {
                if ($('#serarch-warehouse').val() == '') {
                    swal('请选择发货仓库');
                    return false;
                }
                var KindName = $("#serarch-type").val() == '' ? '' : $("#serarch-type").find("option:selected").text();
                var ModelName = $("#serarch-style").val() == '' ? '' : $("#serarch-style").find("option:selected").text();
                var conditionsArr = [];
                conditionsArr.push({ column: "sam.FHStockID", value: $('#serarch-warehouse').val(), operator: "=", connector: "and" });
                conditionsArr.push({ column: "eba.ParentID", value: $('#serarch-province').val(), operator: "=", connector: "and" });
                conditionsArr.push({ column: "ds.AreaID", value: $('#serarch-city').val(), operator: "=", connector: "and" });
                conditionsArr.push({ column: "ds.ShopName", value: $('#search-store').val(), operator: "like", connector: "and" });
                conditionsArr.push({ column: "sam.KindName", value: KindName, operator: "=", connector: "and" });
                conditionsArr.push({ column: "sam.YearNo", value: $('#serarch-year').val(), operator: "=", connector: "and" });
                conditionsArr.push({ column: "sam.SeasonName", value: $('#serarch-season').val(), operator: "=", connector: "and" });
                conditionsArr.push({ column: "sam.MaterialID", value: $('#search-artnum').val(), operator: "=", connector: "and" });
                conditionsArr.push({ column: "sam.ModelName", value: ModelName, operator: "=", connector: "and" });
                conditionsArr.push({ column: "dw.ShopLevelCode", value: $('#serarch-level').val(), operator: "=", connector: "and" });
                if (parseInt($('#serarch-screen').val()) == 1) {
                    conditionsArr.push({ column: "sam.UpdateSuppleQty", value: 0, operator: ">", connector: "and" });
                } else if (parseInt($('#serarch-screen').val()) == 0) {
                    conditionsArr.push({ column: "sam.SuppleQty", value: 0, operator: ">", connector: "and" });
                }
                conditionsArr = JSON.stringify(conditionsArr);
                $.Export({
                    filetype: 'SECONDARYDATA',
                    filename: '辅助数据',
                    conditions: encodeURIComponent(conditionsArr),
                    after: function () {
                        //回调方法
                        //loadList(1);
                        swal("导出成功!");
                    }
                });
            });


            //弹出辅助信息
            $('#leftList').on('click', '.auxiliaryText', function () {
                var tr = $(this).parents('tr');
                var index = tr.index();
                $('#auxiliaryList').empty();
                var tBody = [];
                layer.msg('玩命加载中……', { icon: 16, shade: 0.5, time: 0, maxWidth: 200 });
                Y.API2('DWSuppleAllMessage', 'GetDWAuxiliaryInformationList', {
                    FHStockID: auxiliaryList[index][0]['FHStockID'],
                    ShopCode: auxiliaryList[index][0]['ShopCode'],
                    MaterialID: auxiliaryList[index][0]['MaterialID'],
                }, function (data) {
                    layer.closeAll('dialog');
                    if (data.Success == false) {
                        swal(data.Message, '', 'error');
                    } else {
                        data.map(function (item, i) {
                            var tempTr = {
                                trClass: (i % 2 == 0 ? 'gradeX footable-even' : 'gradeX footable-odd'),
                                children: [
                                    { tdText: (item.ShopName || ' '), c: 0, r: 0, tdHtml: '', tdId: '', tdClass: '' },
                                    { tdText: (item.MaterialCode || ' '), c: 0, r: 0, tdHtml: '', tdId: '', tdClass: '' },
                                    { tdText: (item.SizeName || ' '), c: 0, r: 0, tdHtml: '', tdId: '', tdClass: '' },
                                    { tdText: (item.TotalSaleQty || ' '), c: 0, r: 0, tdHtml: '', tdId: '', tdClass: '' },
                                    { tdText: (item.TotalMoveQty || ' '), c: 0, r: 0, tdHtml: '', tdId: '', tdClass: '' },
                                    { tdText: (item.lifeTotalSaleQty || ' '), c: 0, r: 0, tdHtml: '', tdId: '', tdClass: '' },
                                    { tdText: (item.lifeTotalMoveQty || ' '), c: 0, r: 0, tdHtml: '', tdId: '', tdClass: '' },
                                    { tdText: (item.WeekSaleQty || ' '), c: 0, r: 0, tdHtml: '', tdId: '', tdClass: '' },
                                    { tdText: (item.WeekMoveQty || ' '), c: 0, r: 0, tdHtml: '', tdId: '', tdClass: '' },

                                    { tdText: (item.Validdays || 0), c: 0, r: 0, tdHtml: '', tdId: '', tdClass: '' },
                                    { tdText: (item.ValidWeekSaleQty || 0), c: 0, r: 0, tdHtml: '', tdId: '', tdClass: '' },
                                    { tdText: (item.ValidWeekAvg || 0), c: 0, r: 0, tdHtml: '', tdId: '', tdClass: '' },

                                    { tdText: (item.FirstArriveDate || ' '), c: 0, r: 0, tdHtml: '', tdId: '', tdClass: '' },
                                    { tdText: (item.SaleDays || ' '), c: 0, r: 0, tdHtml: '', tdId: '', tdClass: '' },
                                    { tdText: (item.CalcSaleRate || ' '), c: 0, r: 0, tdHtml: '', tdId: '', tdClass: '' },
                                    { tdText: (item.CZPFlag || ' '), c: 0, r: 0, tdHtml: '', tdId: '', tdClass: '' },
                                    { tdText: (item.PeriodSuppleRate || ''), c: 0, r: 0, tdHtml: '', tdId: '', tdClass: '' },
                                    { tdText: (item.SizeCoreFlag == 0 ? '否' : '是'), c: 0, r: 0, tdHtml: '', tdId: '', tdClass: '' },
                                    { tdText: (item.DisPlayQty || ' '), c: 0, r: 0, tdHtml: '', tdId: '', tdClass: '' },
                                    { tdText: (item.HopeQty || ' '), c: 0, r: 0, tdHtml: '', tdId: '', tdClass: '' },
                                    { tdText: (item.ResultQty || ' '), c: 0, r: 0, tdHtml: '', tdId: '', tdClass: '' },
                                    { tdText: (item.SuppleQty || ' '), c: 0, r: 0, tdHtml: '', tdId: '', tdClass: '' },
                                    { tdText: (item.EndQty || ' '), c: 0, r: 0, tdHtml: '', tdId: '', tdClass: '' },
                                    { tdText: (item.PathQty || ' '), c: 0, r: 0, tdHtml: '', tdId: '', tdClass: '' },
                                    { tdText: (item.OrderPathQty || ' '), c: 0, r: 0, tdHtml: '', tdId: '', tdClass: '' },
                                    { tdText: (item.CanUseQty || ' '), c: 0, r: 0, tdHtml: '', tdId: '', tdClass: '' },
                                    { tdText: (item.MoveOutFlag == 1 ? '是' : ' '), c: 0, r: 0, tdHtml: '', tdId: '', tdClass: '' },
                                ]
                            };
                            tBody.push(tempTr);
                        })
                    }
                    tableControl.initTbody('#auxiliaryTable', (tBody.length > 0 ? tBody : null), 16, null);
                })
            })

            //全选批量维护补货量
            $('#batchTable').on('click', '#checkAllBatch', function () {
                if (this.checked)
                    $('#batchTable .checkBatch').each(function () { this.checked = true; });
                else
                    $('#batchTable .checkBatch').each(function () { this.checked = false; });
            })
            //选择批量维护补货量
            $('#batchTable').on('click', '.checkBatch', function () {
                if ($('#batchTable .checkBatch').size() == $('#batchTable .checkBatch:checked').size())
                    $('#batchTable #checkAllBatch').prop("checked", true);
                else
                    $('#batchTable #checkAllBatch').prop("checked", false);
            });

            //全选仓库店铺信息
            $('.leftTable').on('click', '#checkAll', function () {
                if (this.checked)
                    $('.leftTable .checkItem').each(function () { this.checked = true; });
                else
                    $('.leftTable .checkItem').each(function () { this.checked = false; });
            })
            //选择批量维护补货量
            $('.leftTable').on('click', '.checkItem', function () {
                if ($('.leftTable .checkItem').size() == $('.leftTable .checkItem:checked').size())
                    $('.leftTable #checkAll').prop("checked", true);
                else
                    $('.leftTable #checkAll').prop("checked", false);
            });

            //应用按钮
            $('#application').click(function () {
                var coefficient = parseFloat($('.coefficient').val().trim());
                if (isNaN(coefficient))
                    return false;
                if ($('#batchList .checkBatch:checked').size() == 0) {
                    swal('请选择尺码');
                    return false;
                }
                $('#batchList .checkBatch:checked').each(function () {
                    var $this = $(this);
                    var tr = $this.parents('tr');
                    var sizeID = tr.find('.SizeID').text();
                    $('.leftTable .checkItem:checked').each(function () {
                        var trIndex = $(this).parents('tr').index();
                        var rTr = $('#rightList tr').eq(trIndex);
                        var rV = rTr.find('.setnum.' + sizeID);
                        if (rV.val() != '') {
                            rV.val(Math.ceil(parseInt(rV.val()) * coefficient));
                            rV.blur();
                        }
                    })
                })
            })

            //保存信息
            $('.btns-container').on('click', '#btn-save', function () {
                if ($('#batchList').children().size() == 0) {
                    swal('请输入货号获取SKC信息，再进行保存');
                    return false;
                }
                if ($('#leftList .checkItem:checked').size() == 0) {
                    swal('请选择要保存的信息');
                    return false;
                }

                var submitList = [];
                $('#leftList .checkItem:checked').each(function () {
                    var $this = $(this);
                    var leftTr = $this.parents('tr');
                    var rightTr = $('#rightList tr').eq(leftTr.index());
                    rightTr.find('.setnum').each(function () {
                        var auxiliaryItem = auxiliaryList[leftTr.index()][0];
                        if (!isNaN(parseInt($(this).val()))) {
                            submitList.push({
                                FHStockID: auxiliaryItem.FHStockID,
                                ShopCode: auxiliaryItem.ShopCode,
                                MaterialID: auxiliaryItem.MaterialID,
                                StockDate: auxiliaryItem.StockDate,
                                SizeTypeCode: auxiliaryItem.SizeTypeCode,
                                SizeName: $(this).attr('class').split(' ')[2],
                                SizeID: $(this).attr('class').split(' ')[1],
                                UpdateSuppleQty: $(this).val()
                            })
                        }
                    })
                });
                //  	console.log(submitList);

                layer.msg('玩命加载中……', { icon: 16, shade: 0.5, time: 0, maxWidth: 200 });
                Y.API2('DWSuppleAllMessage', 'ModifyDWSuppleAllMessage', {
                    list: submitList,
                }, function (data) {
                    layer.closeAll('dialog');
                    if (data.Success == false) {
                        swal(data.Message, '', 'error');
                    } else {
                        swal('保存成功', '', 'success');
                    }
                })
            })
        })
    </script>
</asp:Content>

